package squirrel

sealed trait SqlValue {
  def toSQL: String
  def toValue: Any
}
case class SqlValueString(str: String) extends SqlValue {
  override def toSQL: String = "'$str'"

  override def toValue: Any = str
}

case class SqlValueNumber(num: BigDecimal) extends SqlValue {
  override def toSQL: String = s"$num"

  override def toValue: Any = if (num.isWhole()) num.toLong else num.toDouble
}

case class SqlValueBool(b: Boolean) extends SqlValue {
  override def toSQL: String = if (b) "TRUE" else "FALSE"

  override def toValue: Any = b
}

case object SqlValueNull extends SqlValue {
  override def toSQL: String = "NULL"

  override def toValue: Any = null
}
